package cn.wolfcode.wolf2w.search.service.impl;

import cn.wolfcode.wolf2w.search.domian.UserInfoEs;
import cn.wolfcode.wolf2w.search.repository.UserInfoEsRepository;
import cn.wolfcode.wolf2w.search.service.IUserInfoEsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
@Service
public class UserInfoEsServiceImpl implements IUserInfoEsService {
    @Autowired
    private UserInfoEsRepository repository;
    @Override
    public void save(UserInfoEs userInfoEs) {
        repository.save(userInfoEs);
    }

    @Override
    public void update(UserInfoEs userInfoEs) {
        repository.save(userInfoEs);
    }

    @Override
    public UserInfoEs get(String id) {
        return repository.findById(id).orElse(null);
    }

    @Override
    public List<UserInfoEs> list() {
        List<UserInfoEs> list = new ArrayList<>();
        Iterable<UserInfoEs> userInfoEs = repository.findAll();
        userInfoEs.forEach(userInfoEs1 -> list.add(userInfoEs1));
        return list;
    }

    @Override
    public void delete(String id) {
        repository.deleteById(id);
    }
}
